package com.h1909d.weinfo.ui.fragment;

import android.os.Bundle;
import android.support.design.widget.FloatingActionButton;
import android.support.v4.app.Fragment;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import com.h1909d.weinfo.R;
import com.h1909d.weinfo.base.BaseLazyFragment;
import com.h1909d.weinfo.bean.DailyNewsBean;
import com.h1909d.weinfo.presenter.DailyNewsPresenter;
import com.h1909d.weinfo.ui.adapter.RlvDailyNewsAdapter;
import com.h1909d.weinfo.view.DailyNewsView;
import java.util.ArrayList;
import butterknife.BindView;
import butterknife.OnClick;

/**
 * A simple {@link Fragment} subclass.
 */
public class DailyNewsFragment extends BaseLazyFragment<DailyNewsPresenter> implements DailyNewsView {

    @BindView(R.id.rlv)
    RecyclerView mRlv;
    @BindView(R.id.fab)
    FloatingActionButton mFab;
    private RlvDailyNewsAdapter rlvDailyNewsAdapter;

    public static DailyNewsFragment getInstance() {

        DailyNewsFragment fragment = new DailyNewsFragment();
        return fragment;
        // Required empty public constructor
    }

    @Override
    protected void initListener() {

    }

    @Override
    protected void initData() {
        mPresenter.getLastesNews();
    }

    @Override
    protected DailyNewsPresenter initPresenter() {
        return new DailyNewsPresenter();
    }

    @Override
    protected void initView(View view) {
        mRlv.setLayoutManager(new LinearLayoutManager(getContext()));
        ArrayList<DailyNewsBean.TopStoriesBean> bannerList = new ArrayList<>();
        ArrayList<DailyNewsBean.StoriesBean> newsList = new ArrayList<>();

        rlvDailyNewsAdapter = new RlvDailyNewsAdapter(getContext(), bannerList, newsList);
        mRlv.setAdapter(rlvDailyNewsAdapter);
    }

    @OnClick(R.id.fab)
    public void click(View v){
        switch (v.getId()){
            case R.id.fab:
                break;
        }
    }

    @Override
    protected int getLayout() {
        return R.layout.fragment_daily_news;
    }

    @Override
    public void setData(DailyNewsBean dailyNewsBean) {
        rlvDailyNewsAdapter.setData(dailyNewsBean);
    }
}
